﻿
module Sustainalytics.CompanySearch {

    import Common = Sustainalytics.Common;
    import Company = Sustainalytics.Company;
    import SearchBox = Sustainalytics.SearchBox;

    // define company search controller
    export class CompanySearchController {
        private $scope: ng.IScope;
        private $location: ng.ILocationService;
        private searchData: string;

        // Ctor.
        public constructor($scope: ng.IScope, $location: ng.ILocationService) {
            this.$scope = $scope;
            this.$location = $location;

            // associate scope with current instance
            this.$scope['companySearch'] = this;
        }

        // Redirect to company page.
        public goToCompanyPage(company: Company.CorporateDataExtendedDto) {
            var ctx = this;

            // redirect to company page
            this.$location.path('/research/overview/' + company.companyNameUrlFriendly);
        }
    }


    // get module
    var companySearchModule = angular.module('Sustainalytics.CompanySearch');

    // register company search controller
    companySearchModule.controller('CompanySearchController',
        ['$scope', '$location', CompanySearchController]);
}